<?php /* Smarty version 2.6.20, created on 2012-01-11 18:57:07
         compiled from _core/pagecommon/_mvc/_control/handlepagebackendceremony.tpl */ ?>
function HandlePageBackendCeremony(gui, operater, now, options) {
  this._gui = gui;
  this._operator = operater;
  this._now = now;
  this._options = options;
  
  this._createElements();
};

HandlePageBackendCeremony.prototype._createElements = function() {
  this._loadData();
};

HandlePageBackendCeremony.prototype._loadData = function() {
  this._ceremony = null;
  this._retrieveCeremony();
};

HandlePageBackendCeremony.prototype._verifyData = function() {
  if (this._ceremony) {
    this._updateElements();
  }
};

HandlePageBackendCeremony.prototype._retrieveCeremony = function(page, condition, date, from, to, pos) {
  var _self = this;
  if (this._options.id) {
    /*new RequestUtils()._read('iceremony', null, 'd.oid = ' + this._options.id, null, null, null, null, function(result, params) { _self._ceremony = (result.data.length == 1) ? result.data[0] : null;
                                                                                                                                  _self._verifyData.call(_self);
                                                                                                                                }, null);*/
  var args = '&oid=' + this._options.id; 
  new RequestUtils()._mysql('iceremony', args, function(result, params) { _self._ceremony = (result.data.length == 1) ? result.data[0] : null;
                                                                          _self._verifyData.call(_self);
                                                                        }, {php:'customphp/mysqlread.php'});                                                                                                                                  
  } else {
    this._ceremony = ICeremony.instance();
    this._verifyData();
  }
};

HandlePageBackendCeremony.prototype._updateElements = function() {
  var _self = this;

  this._gui.name.value = this._ceremony.name;
  this._gui.name.onchange = function() { _self._ceremony.name = this.value; };
  
  this._gui.save.onclick = function() { if (_self._ceremony.name == '') { 
                                          window.alert('名称不能为空'); 
                                        } else { 
                                          new RequestUtils()._mwrite('iceremony', [_self._ceremony], [], function() { history.back(); }, null); };
                                        }
  this._gui.cancel.onclick = function() { history.back(); };
};
